import os
import torch
def get_cuda_device_num() :
    if not os.environ['CUDA_VISIBLE_DEVICES']:
        return 0
    # _Gpus=len([i for i in os.environ['CUDA_VISIBLE_DEVICES'].split(',')  if int(i)+1 
    #     ])
    # gpu_nums=torch.cuda.device_count()
    # if gpu_nums==_Gpus:
    #     return gpu_nums
    return torch.cuda.device_count()